<?php

namespace app\common\business;

use app\common\lib\Arr;
use app\common\model\mysql\SystemCategory;
use think\db\exception\DataNotFoundException;
use think\db\exception\DbException;
use think\db\exception\ModelNotFoundException;
use think\Exception;
use think\Model;

class Aboutus
{
    public $model = null;

    public function __construct()
    {
        $this->model = new \app\common\model\mysql\Aboutus();
    }

    public function getNormalById($id)
    {
        $info = $this->model->getById($id);
        if (!$info || $info->status != config("status.mysql.table_normal")) {
            return [];
        }
        return $info->toArray();
    }

    /**
     * 新增/保存数据
     * @param $data
     * @return bool
     * @throws DataNotFoundException
     * @throws DbException
     * @throws ModelNotFoundException|Exception
     */
    public function save($data): bool
    {
        if(empty($data['id'])){
            unset($data['id']);
        }
        return $this->model->saveData($data);
    }
}
